package com.myidis.controller;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.myidis.entity.RightUserGroup;
import com.myidis.servlet.RightUserGroupServlet;

import io.swagger.annotations.Api;

@Controller
@RequestMapping("/group")
@Api(tags = "用户组管理接口")
public class RightUserGroupController {
	@Autowired
	private RightUserGroupServlet rightUserGroupServlet;
	
	@ResponseBody
	@RequestMapping("/list")
	public List<RightUserGroup> list() {
		return rightUserGroupServlet.all();
	}
	
	@ResponseBody
	@RequestMapping("/entity")
	public RightUserGroup one(@RequestBody RightUserGroup rightUserGroup) {
		return rightUserGroupServlet.getOne(rightUserGroup.getId());
	}
	
	@ResponseBody
	@RequestMapping("/add")
	public int add(@RequestBody RightUserGroup rightUserGroup) {
		return rightUserGroupServlet.insert(rightUserGroup);
	}
	
	@ResponseBody
	@RequestMapping("/addAll")
	public int addAll(@RequestBody List<RightUserGroup> rightUserGroups) {
		return rightUserGroupServlet.insertAll(rightUserGroups);
	}
	
	@ResponseBody
	@RequestMapping("/upd")
	public int upd(@RequestBody RightUserGroup rightUserGroup) {
		return rightUserGroupServlet.update(rightUserGroup);
	}

	@ResponseBody
	@RequestMapping("/del")
	public int del(@RequestBody int id) {
		return rightUserGroupServlet.delete(id);
	}
	
	@ResponseBody
	@RequestMapping("/delAll")
	public int delAll(@RequestBody int[] ids) {
		return rightUserGroupServlet.deleteAll(ids);
	}
}
